#岗位设置页面
from time import sleep
from common.Untils import WJDriver
from selenium.webdriver.common.by import By

class WJPosition:
    url = ""
    driver = ""

    def __init__(self):
        #WJLogin.WJLogin().LoginSuccess()
        self.url = "http://8.155.1.153:8081/system/position"
        self.driver = WJDriver.driver
        self.driver.get(self.url)
        WJDriver.Login()
        #sleep(2)
        #点击系统管理
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/aside/div/div[1]/ul/li[6]/div/span/div").click()
        self.driver.find_element(By.XPATH,"/html/body/div[1]/div/div/div/section/aside/div/div[1]/ul/li[6]/ul/li[4]").click()

    def TestByRoleFunction(self):
        # self.driver.find_element(By.XPATH,"").send_keys()
        # self.driver.find_element(By.XPATH,"").click()


        #1.输入框中输入要搜索的岗位名称，点击查询
            #输入岗位名称
        sleep(1)
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[1]/form/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("产品经理")
            #点击查询
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[2]/button").click()
        print("岗位设置页面：1正常")
        #2.输入框中输入不存在的岗位名称，点击查询
            #点击重置
        #sleep(1)
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[1]/button").click()
            #输入不存在的岗位
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[1]/form/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("奥特曼")
            #点击查询
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[1]/form/div/div[2]/div/div/div[2]/div/div/div/div/div/div[2]/button").click()
        print("岗位设置页面：2正常")
        #3.点击新建，全部填写
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button").click()
            #填写岗位名称
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("岗位"+WJDriver.name)
            #填写岗位编码
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("编号"+WJDriver.name)
            #选择数据权限
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[2]/div/div/div/div/div[2]/div/div/div/div[1]/span[1]/input").click()
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[2]/div/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[2]/div/div/div/div[1]/div").click()
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        print("岗位设置页面：3正常")
        #4.点击新建，全部不填写
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button").click()
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            #点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("岗位设置页面：4正常")
        #5.点击新建，填写岗位名称，不填写岗位编码，不填写数据权限
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button").click()
            #填写岗位名称
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("岗位"+WJDriver.name)
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            #点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("岗位设置页面：5正常")
        #6.点击新建，不填写岗位名称，填写岗位编码，不填写数据权限
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button").click()
            #填写岗位编码
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("编号"+WJDriver.name)
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
            #点击取消
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[1]/button").click()
        print("岗位设置页面：6正常")
        #7.点击新建，填写岗位名称，填写岗位编码，不填写数据权限
            #点击新建
        self.driver.find_element(By.XPATH, "/html/body/div[1]/div/div/div/section/div[2]/main/div/div[2]/div/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div/div/button").click()
            #填写岗位名称
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[1]/div/div/div[2]/div/div/span/input").send_keys("岗位"+WJDriver.name)
            #填写岗位编码
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[2]/form/div[1]/div/div[2]/div/div/div[2]/div/div/span/input").send_keys("编号"+WJDriver.name)
            #点击确定
        self.driver.find_element(By.XPATH, "/html/body/div[5]/div/div[3]/div/div/div[3]/div/div/div[2]/button").click()
        print("岗位设置页面：7正常")
        print("岗位设置页面全部正常.........")



#         self.driver.quit()
# position=WJPosition()
# position.TestByRoleFunction()